package cn.iocoder.yudao.module.pay.dal.mysql.walletwithdraw;

import cn.iocoder.yudao.framework.common.enums.pay.WithdrawTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pay.controller.admin.walletwithdraw.vo.PayWalletWithdrawPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.walletwithdraw.PayWalletWithdrawDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 钱包提现 Mapper
 *
 * @author FFFF
 */
@Mapper
public interface PayWalletWithdrawMapper extends BaseMapperX<PayWalletWithdrawDO> {

    default PageResult<PayWalletWithdrawDO> selectPage(PayWalletWithdrawPageReqVO reqVO) {
        LambdaQueryWrapperX<PayWalletWithdrawDO> wrapperX = new LambdaQueryWrapperX<PayWalletWithdrawDO>()
                .eqIfPresent(PayWalletWithdrawDO::getWalletId, reqVO.getWalletId())
                .eqIfPresent(PayWalletWithdrawDO::getUserId, reqVO.getUserId())
                .eqIfPresent(PayWalletWithdrawDO::getPrice, reqVO.getPrice())
                .eqIfPresent(PayWalletWithdrawDO::getFeePrice, reqVO.getFeePrice())
                .eqIfPresent(PayWalletWithdrawDO::getType, reqVO.getType())
                .likeIfPresent(PayWalletWithdrawDO::getName, reqVO.getName())
                .eqIfPresent(PayWalletWithdrawDO::getAccountNo, reqVO.getAccountNo())
                .likeIfPresent(PayWalletWithdrawDO::getBankName, reqVO.getBankName())
                .eqIfPresent(PayWalletWithdrawDO::getBankAddress, reqVO.getBankAddress())
                .eqIfPresent(PayWalletWithdrawDO::getAccountQrCodeUrl, reqVO.getAccountQrCodeUrl())
                .eqIfPresent(PayWalletWithdrawDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PayWalletWithdrawDO::getAuditReason, reqVO.getAuditReason())
                .betweenIfPresent(PayWalletWithdrawDO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(PayWalletWithdrawDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(PayWalletWithdrawDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PayWalletWithdrawDO::getId);
        if (reqVO.getType() == null) {
            wrapperX.lt(PayWalletWithdrawDO::getType, WithdrawTypeEnum.PAYMENT.getType());
        }
        return selectPage(reqVO, wrapperX);
    }

}